#ifndef CUSTOMEVENT_H
#define CUSTOMEVENT_H

#include <QEvent>
#include <QString>
#include "TcpServer.h"

// 注册自定义事件类型
#define CSTM_EVENT_BASE                        static_cast<QEvent::Type>((QEvent::User + 1))
#define CSTM_EVENT_DEVICE_HEARTBEAT            static_cast<QEvent::Type>((QEvent::User + 2))
#define CSTM_EVENT_CONNECT                     static_cast<QEvent::Type>((QEvent::User + 3))
#define CSTM_EVENT_DISCONNECT                  static_cast<QEvent::Type>((QEvent::User + 4))

class CustomEvent : public QEvent
{
public:
    CustomEvent();
    ~CustomEvent();
};

class DeviceHeartbeatEvent : public QEvent
{
public:
    DeviceHeartbeatEvent(const hv::SocketChannelPtr& channel, const QString& imei);
    ~DeviceHeartbeatEvent();
    hv::SocketChannelPtr channel();
    QString imei();

private:
    const hv::SocketChannelPtr _channel;
    const QString _imei;
};

class ConnectEvent : public QEvent
{
public:
    ConnectEvent(const hv::SocketChannelPtr& channel);
    ~ConnectEvent();
    hv::SocketChannelPtr channel();
private:
   const hv::SocketChannelPtr _channel;
};

class DisconnectEvent : public QEvent
{
public:
    DisconnectEvent(const hv::SocketChannelPtr& channel);
    ~DisconnectEvent();
    hv::SocketChannelPtr channel();
private:
   const hv::SocketChannelPtr _channel;
};

#endif // CUSTOMEVENT_H
